/*
 */
package org.actorsguildframework;

import java.io.IOException;

import junit.framework.Assert;

import org.junit.Test;

/**
 * Unit tests for WrappedException.
 */
public class WrappedExceptionTest {
	@Test(expected=IOException.class)
	public void testRethrow() throws Throwable {
		IOException ie = new IOException("foo");
		WrappedException we = new WrappedException("bar", ie);
		Assert.assertSame(ie, we.getCause());
		we.rethrow();
	}

	@Test(expected=IOException.class)
	public void testRethrowIf() throws Exception {
		IOException ie = new IOException("foo");
		WrappedException we = new WrappedException("bar", ie);
		we.rethrowIf(IndexOutOfBoundsException.class);
		we.rethrowIf(IOException.class);
	}
	
	@Test
	public void testIsWrapping() throws Exception {
		IOException ie = new IOException("foo");
		WrappedException we = new WrappedException("bar", ie);
		Assert.assertFalse(we.isWrapping(IndexOutOfBoundsException.class));
		Assert.assertTrue(we.isWrapping(IOException.class));
	}

}
